//
//  ViewController.m
//  UI09_UITabBarController
//
//  Created by wyx on 16/3/21.
//  Copyright © 2016年 Apon. All rights reserved.
//

#import "ViewController.h"
#import "VCOfSecondTabBarItem.h"
#import "SecondViewControllerOfFirstTabBar.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    self.view.backgroundColor = [UIColor yellowColor];
    self.navigationItem.title = @"首页";
    [self createButton];
}
- (void)createButton{
    UIButton *button1 = [UIButton buttonWithType:UIButtonTypeSystem];
    button1.frame  = CGRectMake(100, 100, 100, 50);
    button1.backgroundColor = [UIColor cyanColor];
    [button1 setTitle:@"已读" forState: UIControlStateNormal];
    [self.view addSubview:button1];
    [button1 addTarget:self action:@selector(handleOfButton:) forControlEvents:UIControlEventTouchUpInside];
    [button1 release];
    
    UIButton *button2 = [UIButton buttonWithType:UIButtonTypeSystem];
    button2.frame = CGRectMake(100, 200, 100, 50);
    button2.backgroundColor = [UIColor cyanColor];
    [button2 setTitle:@"下一页" forState: UIControlStateNormal];
    [self.view addSubview:button2];
    [button2 addTarget:self action:@selector(handleOfButton2:) forControlEvents:UIControlEventTouchUpInside];
    [button2 release];
}
//角标清除
-(void)handleOfButton:(UIButton *)button1{
    //找到相应的tabBarItem 对象
    self.navigationController.tabBarItem.badgeValue = nil;
}
- (void)handleOfButton2:(UIButton *)button2{
    SecondViewControllerOfFirstTabBar *second = [[SecondViewControllerOfFirstTabBar alloc] init];
    [self.navigationController pushViewController:second animated:NO];
    [second release];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
